package com.tanhua.server.controller;

import com.tanhua.model.vo.QuestionnaireReportVo;
import com.tanhua.model.vo.QuestionnaireVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Desciption:test
 * @Create by:金木yan
 * @Date: 2021/12/11 17:02
 */
@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
    private TestSoulService testSoulService;

    /**
     * 查询问卷列表
     */
    @GetMapping
    public ResponseEntity soulList() {
        List<QuestionnaireVo> list = testSoulService.soulList();
        return ResponseEntity.ok(list);
    }

    /**
     * 根据报告id查询报告
     */
    @GetMapping("/report/{id}")
    public ResponseEntity report(@PathVariable String id) {
        QuestionnaireReportVo reportVo = testSoulService.findReport(id);
        return ResponseEntity.ok(reportVo);
    }

    /**
     * 提交问卷
     */
    @PostMapping
    public ResponseEntity commit(@RequestBody Map map) {
        String reportId = testSoulService.commit(map);
        return ResponseEntity.ok(reportId);
    }
}
